// 箭头函数与 this

const person = {
    name: 'tom',
    // sayHi: function () {
    //     console.log(`hi, my name is ${this.name}`)
    // }

    sayHi: () => {
        console.log(`hi, my name is ${this.name}`);
    },

    // sayHiAsync: function () {
    //     setTimeout(function () {
    //         console.log(this.name)
    //     }, 1000);
    // },

    sayHiAsync: function () {
        setTimeout(() => {
            console.log(this.name);
        }, 1000);
    },
};

person.sayHi();
person.sayHiAsync();
